 package cn.edu.ujn.finalwork.service;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.edu.ujn.finalwork.dao.Base;
import cn.edu.ujn.finalwork.dao.BaseMapper;
@Service
public class BaseServiceImpl implements IBaseService {
    @Autowired
    BaseMapper baseMapper;

    @Override
    public int insert(Base user) {
        int insert = baseMapper.insert(user);
        return insert;
    }

    @Override
    public int updateByPrimaryKey(Base user) {
        int i = baseMapper.updateByPrimaryKey(user);
        return i;
    }

    @Override
    public int insertSelective(Base row) {
        int i = baseMapper.insertSelective(row);
        return i;
    }

    @Override
    public Base selectByPrimaryKey(String id) {
        Base base=baseMapper.selectByPrimaryKey(id);
        return base;
    }

    @Override
    public Base selectByType_CodeAndType_Name(Base base) {
        Base base2 = baseMapper.selectByType_CodeAndType_Name(base);
        return base2;
        
    }

    @Override
    public int updateByPrimaryKeySelective(Base row) {
        int i = baseMapper.updateByPrimaryKeySelective(row);
        return i;
    }

    @Override
    public int deleteByPrimaryKey(String id) {
        int i = baseMapper.deleteByPrimaryKey(id);
        return i;   
    }

    @Override
    public List<Base> selectAll() {
       List<Base> all = baseMapper.selectAll();
       return all;
    }

    @Override
    public List<Base> selectByTName(String name) {
        List<Base> list = baseMapper.selectByTName(name);
        return list;
    }

    @Override
    public List<String> type() {
        List<String> list=new ArrayList<String>();
        list.add("全部数据");
        List<Base> all = baseMapper.selectAll();
        for(Base b:all) {
            String n=b.getDictTypeName();
            if (!list.contains(n))
            {
                list.add(b.getDictTypeName());
            }
        }
        return list;
    }

    @Override
    public List<Base> selectAllNum() {
         List<Base> all = baseMapper.selectAllNum();
           return all;
    }

    @Override
    public List<String> selectIName(String TCode) {
        List<String> list = baseMapper.selectIName(TCode);
         return list;
    }

    @Override
    public String selectTCode(String IName) {
        String list = baseMapper.selectTCode(IName);
        return list;
    }

}
